package com.zbkj.admin.controller.merchant;

import com.zbkj.common.model.Warehouse;
import com.zbkj.common.page.CommonPage;
import com.zbkj.common.request.PageParamRequest;
import com.zbkj.common.request.WarehouseSearchRequest;
import com.zbkj.common.result.CommonResult;
import com.zbkj.service.service.WarehouseService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;


/**
 * 仓库表 前端控制器
 */
@Slf4j
@RestController
@RequestMapping("api/admin/merchant/warehouse")
@Api(tags = "仓库表")
public class MerchantWarehouseController {

    @Autowired
    private WarehouseService warehouseService;

    /**
     * 分页显示仓库表
     *
     * @param request          搜索条件
     * @param pageParamRequest 分页参数
     * @author keNan
     * @since 2025-06-05
     */
    @PreAuthorize("hasAuthority('merchant:warehouse:list')")
    @ApiOperation(value = "仓库分页列表")
    @RequestMapping(value = "/list", method = RequestMethod.GET)
    public CommonResult<CommonPage<Warehouse>> getList(@Validated WarehouseSearchRequest request, @Validated PageParamRequest pageParamRequest) {
        CommonPage<Warehouse> warehouseCommonPage = CommonPage.restPage(warehouseService.getList(request, pageParamRequest));
        return CommonResult.success(warehouseCommonPage);
    }


    /**
     * 查询仓库表信息
     *
     * @param id Integer
     * @author keNan
     * @since 2025-06-05
     */
    @PreAuthorize("hasAuthority('merchant:warehouse:info')")
    @ApiOperation(value = "详情")
    @RequestMapping(value = "/info", method = RequestMethod.GET)
    public CommonResult<Warehouse> info(@RequestParam(value = "id") Integer id) {
        Warehouse warehouse = warehouseService.getById(id);
        return CommonResult.success(warehouse);
    }


}



